﻿using LeakView.common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeakView.misc
{
    class Miscs
    {

        static Miscs()
        {
            HeadColor = GetMiscColorFromConfig("HeadColor", Color.Blue);
            TailColor = GetMiscColorFromConfig("TailColor", Color.Green);
        }


        #region 曲线时间范围

        public static TimeSpan MiscChartTimeSpan { get => TimeSpan.FromMinutes(MiscChartTimeMinutes); }

        public static int MiscChartTimeMinutes { get; set; } = 30;


        #endregion


        #region 曲线颜色

        public static Color HeadColor { get; } = Color.Blue;

        public static Color TailColor { get; } = Color.Green;


        private static Color GetMiscColorFromConfig(string key, Color def)
        {
            try
            {
                var config = AnyConfigs.get("MISC");
                string colorString = config.get(key).Get<string>();
                return ColorTranslator.FromHtml(colorString);
            }
            catch
            {
                return def;
            }
        }

        #endregion
    }
}
